package com.cvnert.testplatform.controller;


import com.cvnert.testplatform.domain.vo.TaskListVo;
import com.cvnert.testplatform.domain.vo.TaskVo;
import com.cvnert.testplatform.service.TaskService;
import com.cvnert.testplatform.utils.ResultJson;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/task")
public class TaskController {
    @Resource
    private TaskService taskService;

    @PostMapping("/addTask")
    public ResultJson<Object> getTaskList(@RequestBody TaskVo taskVo){
        return ResultJson.success(taskService.addTask(taskVo));
    }

    @GetMapping("/deleteTask/{tid}")
    public ResultJson<Object> deleteTask(@PathVariable Integer tid){
        return ResultJson.success(taskService.deleteTask(tid));
    }

    @PostMapping("/updateTask")
    public ResultJson<Object> updateTask(@RequestBody TaskVo taskVo){
        return ResultJson.success(taskService.updateTask(taskVo));
    }

    @PostMapping("/getTaskList")
    public ResultJson<Object> getTaskList(@RequestBody TaskListVo taskListVo){
        return ResultJson.success(taskService.getTaskList(taskListVo));
    }

    @GetMapping("/getTaskDetail/{tid}")
    public ResultJson<Object> getTaskDetail(@PathVariable Integer tid){
        return ResultJson.success(taskService.getTaskDetail(tid));
    }


}
